package com.it.you.base.stringbuilder;

import java.util.ArrayList;
import java.util.List;

public class StringBuilderTest1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("");
//        list.add("ma");
//        list.add("tian");
        StringBuilder builder = new StringBuilder();
        for (String s : list) {
            if (s != null) {
                builder.append(s).append(",");
            }
        }

        System.out.println(builder);
        if (builder.length() > 0) {
            //删除最后的分隔符
            builder.deleteCharAt(builder.length() - 1);
        }
        System.out.println(builder);
    }
}
